import React, { Component } from 'react'
import { Table, Button } from 'antd'

class Product extends Component{
  state = {
    goods: [] // 所有用户列表
  }
  initColumns = () => {
    this.columns = [
      {
        title: '名称',
        dataIndex: 'username'
      },
      {
        title: '主图',
        dataIndex: 'email'
      },
      {
        title: '分类',
        dataIndex: 'phone'
      },
      {
        title: '库存',
        dataIndex: 'role_id'
      },
      {
        title: '操作',
        render: (user) => (
          <span>
            <Button type="primary" size="small" onClick={() => this.showUpdate(user)}>上架</Button>
            <Button type="primary" size="small" onClick={() => this.deleteUser(user)}>删除</Button>
          </span>
        )
      },
    ]
  }
  componentWillMount () {
    this.initColumns()
  }
  render() {
    return (
      <div calssName="product">
        <Table bordered rowKey='_id' dataSource={this.state.goods} columns={this.columns}></Table>
      </div>
    )
  }
}
export default Product